/*
	Copyright (C) 2009 jungil Han <jungil.Han@gmail.com>

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef __MKHOTKEYMANAGER_H__
#define __MKHOTKEYMANAGER_H__

#include "../Base/mkBase.h"
#include <QList>
#include <QString>

class QObject;

typedef struct _mkHotkeyInfo {
	int nButtonID;
	int nSystemKey;
	int nNonSystemKey;
	QString strFileName;
} mkHotkeyInfo;

class mkHotkeyManager {
public:
	void SetParent( IN QObject *a_pParent );
	
	void LoadfromFile();
	void SavetoFile();

	void AddHotkey( IN int a_nButtonID, IN int a_nSystemKey, IN int a_nNonSystemKey, IN QString a_strFileName );
	void RemoveHotkeyAt( IN int a_nButtonID );
	void RemoveHotkeyAll();

	void RegisterHotkeyAt( IN int a_nButtonID );
	void RegisterHotkeyAll();
	
	void UnregisterHotkeyAt( IN int a_nButtonID );
	void UnregisterHotkeyAll();
	
	QString GetFileName( IN int a_nSystemKey, IN int a_nNonSystemKey );
	const QList<mkHotkeyInfo> GetList();

	void SortByHotkey();
	
	static mkHotkeyManager* Instance();
	
protected:
	void ParseHotkeyInfo( IN QString &a_refHotkeyInfo );
	
	void SortByID();
	static bool LessThanID( IN const mkHotkeyInfo &a_refHotkey1, IN const mkHotkeyInfo &a_refHotkey2 );
	static bool MoreThanHotkey( IN const mkHotkeyInfo &a_refHotkey1, IN const mkHotkeyInfo &a_refHotkey2 );
	
private:
	/* Disable constructor and destructors*/
	mkHotkeyManager() { m_pParent = NULL; }
	~mkHotkeyManager() {}

	static mkHotkeyManager *s_pThis;

	QObject *m_pParent;
	QList<mkHotkeyInfo> m_hotkeyInfoList;
};

#endif
